package com.ruoyi.cqjd.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.cqjd.mapper.CqjdShoppingCartMapper;
import com.ruoyi.cqjd.domain.CqjdShoppingCart;
import com.ruoyi.cqjd.service.ICqjdShoppingCartService;

/**
 * 购物车Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-06-19
 */
@Service
public class CqjdShoppingCartServiceImpl implements ICqjdShoppingCartService 
{
    @Autowired
    private CqjdShoppingCartMapper cqjdShoppingCartMapper;

    /**
     * 查询购物车
     * 
     * @param id 购物车主键
     * @return 购物车
     */
    @Override
    public CqjdShoppingCart selectCqjdShoppingCartById(Long id)
    {
        return cqjdShoppingCartMapper.selectCqjdShoppingCartById(id);
    }

    /**
     * 查询购物车列表
     * 
     * @param cqjdShoppingCart 购物车
     * @return 购物车
     */
    @Override
    public List<CqjdShoppingCart> selectCqjdShoppingCartList(CqjdShoppingCart cqjdShoppingCart)
    {
        return cqjdShoppingCartMapper.selectCqjdShoppingCartList(cqjdShoppingCart);
    }

    /**
     * 新增购物车
     * 
     * @param cqjdShoppingCart 购物车
     * @return 结果
     */
    @Override
    public int insertCqjdShoppingCart(CqjdShoppingCart cqjdShoppingCart)
    {
        cqjdShoppingCart.setCreateTime(DateUtils.getNowDate());
        return cqjdShoppingCartMapper.insertCqjdShoppingCart(cqjdShoppingCart);
    }

    /**
     * 修改购物车
     * 
     * @param cqjdShoppingCart 购物车
     * @return 结果
     */
    @Override
    public int updateCqjdShoppingCart(CqjdShoppingCart cqjdShoppingCart)
    {
        return cqjdShoppingCartMapper.updateCqjdShoppingCart(cqjdShoppingCart);
    }

    /**
     * 批量删除购物车
     * 
     * @param ids 需要删除的购物车主键
     * @return 结果
     */
    @Override
    public int deleteCqjdShoppingCartByIds(Long[] ids)
    {
        return cqjdShoppingCartMapper.deleteCqjdShoppingCartByIds(ids);
    }

    /**
     * 删除购物车信息
     * 
     * @param id 购物车主键
     * @return 结果
     */
    @Override
    public int deleteCqjdShoppingCartById(Long id)
    {
        return cqjdShoppingCartMapper.deleteCqjdShoppingCartById(id);
    }

    @Override
    public List<CqjdShoppingCart> getListByUserId(Long userId) {
        return cqjdShoppingCartMapper.getListByUserId(userId);
    }

    @Override
    public CqjdShoppingCart getOneByDishId(Long dishId) {
        return cqjdShoppingCartMapper.getOneByDishId(dishId);
    }

    @Override
    public CqjdShoppingCart getOneByUserIdAndDishId(CqjdShoppingCart cqjdShoppingCart) {
        return cqjdShoppingCartMapper.getOneByUserIdAndDishId(cqjdShoppingCart);
    }

    @Override
    public void removeByUserId(Long userId) {
        cqjdShoppingCartMapper.removeByUserId(userId);
    }
}
